package cn.gson.fengboot.controller;

import cn.gson.fengboot.model.pojos.Zorder;
import cn.gson.fengboot.model.pojos.Zorderdetails;
import cn.gson.fengboot.model.service.ZorderService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/dindan")
public class ZorderController {
    @Autowired
    ZorderService ddservice;

    //订单弹出框查询方法
    @RequestMapping("/list_dd")
    @ResponseBody
    public Map<String,Object> kaipiao(Integer page, Integer size,String search,String search2,String search3){
        Page<Object> obj = PageHelper.startPage(page, size);
        ddservice.ddlist(search,search2,search3);

        Map<String,Object> map = new HashMap<>();
        map.put("total",obj.getTotal());
        map.put("rows",obj.getResult());
        return map;
    }

    //订单弹出框查询方法
    @RequestMapping("/list_dd2")
    @ResponseBody
    public Map<String,Object> kaipiao2(Integer page, Integer size,String search,String search2){
        Page<Object> obj = PageHelper.startPage(page, size);
        ddservice.ddlist2(search,search2);

        Map<String,Object> map = new HashMap<>();
        map.put("total",obj.getTotal());
        map.put("rows",obj.getResult());
        return map;
    }

    //订单详情查询方法
    @RequestMapping("/list_ddxq")
    @ResponseBody
    public List<Zorderdetails> ddxqlist(Integer search){
        return ddservice.ddxqlist(search);
    }

    //订单详情查询方法
    @RequestMapping("/list_ddxqcp")
    @ResponseBody
    public List<Zorderdetails> allpro(Integer search){
        return ddservice.allpro(search);
    }

    //按照订单id查询详情查询方法
    @RequestMapping("/list_ddxqcp2")
    @ResponseBody
    public Map<String,Object> allpro2(Integer page, Integer size,Integer search,String search2,String search3){
        Page<Object> obj = PageHelper.startPage(page, size);
        ddservice.allpro2(search,search2,search3);

        Map<String,Object> map = new HashMap<>();
        map.put("total",obj.getTotal());
        map.put("rows",obj.getResult());
        return map;
    }

    //按照订单id查询详情查询方法
    @RequestMapping("/kehu_list")
    @ResponseBody
    public Map<String,Object> kehulist(Integer page, Integer size,Integer search){
        Page<Object> obj = PageHelper.startPage(page, size);
        ddservice.kehulist(search);

        Map<String,Object> map = new HashMap<>();
        map.put("total",obj.getTotal());
        map.put("rows",obj.getResult());
        return map;
    }

    //按照订单id查询详情查询方法
    @RequestMapping("/heton_dd")
    @ResponseBody
    public List<Zorder> ddlistheton(Integer search){
        return ddservice.ddlistheton(search);
    }

    //按照订单id查询详情查询方法
    @RequestMapping("/hh_dd")
    @ResponseBody
    public List<Zorder> ddlisthh(Integer search){
        return ddservice.ddlisthh(search);
    }

    //订单新增方法
    @RequestMapping("/add")
    @ResponseBody
    public void add(@RequestBody Zorder dd){
        ddservice.add(dd);
    }

    //订单删除方法
    @RequestMapping("/delete")
    @ResponseBody
    public Integer sc(@RequestBody Zorder dd){
       return ddservice.sc(dd);
    }
}
